﻿<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
       "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<link rel="stylesheet" type="text/css" href="../style.css">
<meta http-equiv="content-type" content="text/html; charset=utf-8">
</head>
<body>


<form action="gruppe_spiel_anlegen_v.php" method="post">

<table>

<?php

	include("../inc/joomlaInt_admin.php");
	include("../inc/inc_configuration.php");
	
	if ($jUser==0)
	{
		echo "Bitte zuerst einloggen!";
	}
	else
	{
		$gruppe=$_GET["gruppe"];
		
		$lq = "SELECT * FROM $tbl_gt WHERE groupId=$gruppe";
		$lqe = mysql_query($lq);
		$lqc = mysql_num_rows($lqe);

		
		if ($lqc % 2 ==0)
		{
			$mAnz = ($lqc-1)*2;
		}
		else
		{
			$mAnz = $lqc*2;
		}
		
		echo'<tr>
				<td>Spieltag:</td>
				<td><select name="matchday" Size="1">';
		
		$count = 1;
		while($count < $mAnz+1)
		{
			echo '<Option Value="',$count,'">',$count,'</option>';
			$count++;
		}
		echo"</select></td></tr>";
		
		$q="SELECT l.id FROM $tbl_leagues l, $tbl_lg lg WHERE l.id=lg.leagueId AND lg.id=$gruppe";
		$qe=mysql_query($q);
		$qeo=mysql_fetch_object($qe);
		
		$liga=$qeo->id;
		
		$q = "SELECT * FROM $tbl_lg WHERE leagueId=$liga";
		$qe = mysql_query($q);
		
		
		echo '<tr>
				<td>Gruppe:</td>
				<td><select name="stage" Size="1">';
				
		while ($qeo=mysql_fetch_object($qe))
		{
			echo'<Option selected Value="',$gruppe,'">' ,$qeo->groupName, '</option>';
		}

			
		echo"</select></td></tr>";
		
		
		
		$abfrage = "SELECT t.id, t.name FROM $tbl_teams t, $tbl_gt gt WHERE gt.groupId=$gruppe AND gt.teamId=t.id ORDER BY name";
		$ergebnis = mysql_query($abfrage);
		
		echo '<tr>
				<td>Heim:</td>
				<td><select name="homeTeam" Size="1">';
		
		while ($row = mysql_fetch_object($ergebnis))
			{
				echo '<Option Value="',$row->id,'">' ,$row->name, '</option>';
			}
			
		echo"</select></td></tr>";
		

		$ergebnis = mysql_query($abfrage);
		
		echo '<tr>
				<td>Gast:</td>
				<td><select name="guestTeam" Size="1">';
		
		
		while ($row = mysql_fetch_object($ergebnis))
			{
				$t=$row->id;
				echo '<Option Value="',$t,'">' ,$row->name, '</option>';
			}
			
		echo "</select></td></tr>";
		
		echo " 		<tr>
						<td>Status:</td>
						<td>
							<select name='free'>
								<option value='0'>Nicht freigegeben</option>
								<option value='1'>Freigegeben</option>
								<option value='2'>Warten auf Bestätigung</option>
								<option value='3'>Bestätigt</option>
							</select>
						</td>
					</tr>
				</table>";
		
		echo '	<input type="text" name="liga" value="',$liga,'" hidden>
				<input type="text" name="gruppe" value="',$gruppe,'" hidden>';


		;


	echo '	<br>
			<input type="submit" value="Anlegen" class="button anlegen">
			</form>';

	echo "<center><a href='gruppenspiele.php?gruppe=",$gruppe,"' class='button zurueck'>Zurück</a></center>";
}
?>
</body>
</html>

